//文件的写操作5
import java.io.*;
public class Demo16 {
    public static void main(String[] args) throws IOException{
        try(OutputStream out = new FileOutputStream("hello7.txt")){ 
            try(OutputStreamWriter writer = new OutputStreamWriter(out,"utf-8")){
                try(PrintWriter pw = new PrintWriter(writer)){ //PrintWriter可以方便地打印各种数据类型
                    pw.println("Hello"); //打印字符串
                    pw.println(12345); //打印整数
                    pw.println(3.1415926); //打印浮点数
                    pw.println(true); //打印布尔值
                    pw.printf("Hello, %s, 你好，%s", "world", "世界"); //格式化打印字符串
                    pw.flush(); //千万不要忘记flush
                }
            }
        }
    }
}
